package com.huohuzhihui.web.controller.merchant;

import com.huohuzhihui.common.annotation.Log;
import com.huohuzhihui.common.core.controller.BaseController;
import com.huohuzhihui.common.core.domain.AjaxResult;
import com.huohuzhihui.common.core.page.TableDataInfo;
import com.huohuzhihui.common.enums.BusinessType;
import com.huohuzhihui.common.utils.poi.ExcelUtil;
import com.huohuzhihui.merchant.domain.MerActivityVideo;
import com.huohuzhihui.merchant.service.IMerActivityVideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 商家活动视频Controller
 * 
 * @author huohuzhihui
 * @date 2021-04-01
 */
@RestController
@RequestMapping("/merchant/activityvideo")
public class MerActivityVideoController extends BaseController
{
    @Autowired
    private IMerActivityVideoService merActivityVideoService;

    /**
     * 查询商家活动视频列表
     */
    @PreAuthorize("@ss.hasPermi('merchant:activityvideo:list')")
    @GetMapping("/list")
    public TableDataInfo list(MerActivityVideo merActivityVideo)
    {
        startPage();
        List<MerActivityVideo> list = merActivityVideoService.selectMerActivityVideoList(merActivityVideo);
        return getDataTable(list);
    }

    /**
     * 导出商家活动视频列表
     */
    @PreAuthorize("@ss.hasPermi('merchant:activityvideo:export')")
    @Log(title = "商家活动视频", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MerActivityVideo merActivityVideo)
    {
        List<MerActivityVideo> list = merActivityVideoService.selectMerActivityVideoList(merActivityVideo);
        ExcelUtil<MerActivityVideo> util = new ExcelUtil<MerActivityVideo>(MerActivityVideo.class);
        return util.exportExcel(list, "activityvideo");
    }

    /**
     * 获取商家活动视频详细信息
     */
    @PreAuthorize("@ss.hasPermi('merchant:activityvideo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(merActivityVideoService.selectMerActivityVideoById(id));
    }

    /**
     * 新增商家活动视频
     */
    @PreAuthorize("@ss.hasPermi('merchant:activityvideo:add')")
    @Log(title = "商家活动视频", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MerActivityVideo merActivityVideo)
    {
        return toAjax(merActivityVideoService.insertMerActivityVideo(merActivityVideo));
    }

    /**
     * 修改商家活动视频
     */
    @PreAuthorize("@ss.hasPermi('merchant:activityvideo:edit')")
    @Log(title = "商家活动视频", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MerActivityVideo merActivityVideo)
    {
        return toAjax(merActivityVideoService.updateMerActivityVideo(merActivityVideo));
    }

    /**
     * 删除商家活动视频
     */
    @PreAuthorize("@ss.hasPermi('merchant:activityvideo:remove')")
    @Log(title = "商家活动视频", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(merActivityVideoService.deleteMerActivityVideoByIds(ids));
    }
}
